package cn.com.blueInfo.bpm.person.controller;

import cn.com.blueInfo.bpm.common.controller.BaseController;
import cn.com.blueInfo.bpm.common.validation.Create;
import cn.com.blueInfo.bpm.common.validation.Update;
import cn.com.blueInfo.bpm.common.validation.UpdatePartial;
import cn.com.blueInfo.bpm.person.request.OrganizeLevelDTO;
import cn.com.blueInfo.bpm.person.response.OrganizeLevelVO;
import cn.com.blueInfo.bpm.person.service.OrganizeLevelService;
import cn.com.blueInfo.utils.result.ResultInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.groups.Default;
import java.util.List;

/**
 * 组织级别表 前端控制器
 * @author suxch
 * @since 2025-08-24 01:39:52
 */
@Tag(name = "组织级别 接口")
@RestController
@RequestMapping("/person/organizeLevel")
public class OrganizeLevelController extends BaseController {

    @Autowired
    private OrganizeLevelService organizeLevelService;

    /**
     * 新建组织级别
     * @param organizeLevelDTO 组织级别参数
     * @return ResultInfo
     */
    @Operation(summary = "新增组织级别")
    @PostMapping("/addInfo")
    public ResultInfo<Integer> createOrganizeLevel(
            @Validated({Create.class, Default.class}) @RequestBody OrganizeLevelDTO organizeLevelDTO) {
        return organizeLevelService.addOrganizeLevel(organizeLevelDTO);
    }

    /**
     * 批量新建组织级别
     * @param organizeLevelDTOList 组织级别参数列表
     * @return ResultInfo
     */
    @Operation(summary = "批量新建组织级别")
    @PostMapping("/addInfoList")
    public ResultInfo<Integer> batchCreateOrganizeLevel(
            @Validated({Create.class, Default.class}) @RequestBody List<OrganizeLevelDTO> organizeLevelDTOList) {
        return organizeLevelService.batchAddOrganizeLevel(organizeLevelDTOList);
    }

    /**
     * 根据ID删除组织级别
     * @param organizeLevelId 组织级别ID
     * @return ResultInfo
     */
    @Operation(summary = "根据ID删除组织级别")
    @DeleteMapping("/removeInfo/{organizeLevelId}")
    public ResultInfo<Integer> deleteOrganizeLevelById(
            @Parameter(name = "ID") @PathVariable Long organizeLevelId) {
        return organizeLevelService.removeOrganizeLevel(organizeLevelId);
    }

    /**
     * 批量根据ID删除组织级别
     * @param organizeLevelIdList 组织级别ID列表
     * @return ResultInfo
     */
    @Operation(summary = "批量根据ID删除组织级别")
    @DeleteMapping("/removeInfoList/{organizeLevelIdList}")
    public ResultInfo<Integer> batchDeleteOrganizeLevelById(
            @Parameter(name = "ID") @PathVariable List<Long> organizeLevelIdList) {
        return organizeLevelService.batchRemoveOrganizeLevel(organizeLevelIdList);
    }

    /**
     * 根据ID全量更新组织级别
     * @param organizeLevelId 组织级别ID
     * @param organizeLevelDTO 组织级别参数
     * @return ResultInfo
     */
    @Operation(summary = "根据ID全量更新组织级别")
    @PutMapping("/modifyInfo/{organizeLevelId}")
    public ResultInfo<Integer> updateOrganizeLevelFull(
            @Parameter(name = "ID") @PathVariable Long organizeLevelId,
            @Validated({Update.class, Default.class}) @RequestBody OrganizeLevelDTO organizeLevelDTO) {
        validateUpdateId(organizeLevelId, organizeLevelDTO.getId());
        return organizeLevelService.modifyOrganizeLevel(organizeLevelDTO);
    }

    /**
     * 根据ID部分更新组织级别
     * @param organizeLevelId 组织级别ID
     * @param organizeLevelUpdatePartialDTO 组织级别参数
     * @return ResultInfo
     */
    @Operation(summary = "根据ID部分更新组织级别")
    @PatchMapping("/modifyPartialInfo/{organizeLevelId}")
    public ResultInfo<Integer> updateOrganizeLevelPartial(
            @Parameter(name = "ID") @PathVariable Long organizeLevelId,
            @Validated({UpdatePartial.class, Default.class}) @RequestBody
            OrganizeLevelDTO.UpdatePartialDTO organizeLevelUpdatePartialDTO) {
        validateUpdateId(organizeLevelId, organizeLevelUpdatePartialDTO.getId());
        return organizeLevelService.modifyOrganizeLevelPartial(organizeLevelUpdatePartialDTO);
    }

    /**
     * 根据ID查询组织级别
     * @param organizeLevelId 组织级别ID
     * @return ResultInfo
     */
    @Operation(summary = "根据ID查询组织级别")
    @GetMapping("/getInfo/{organizeLevelId}")
    public ResultInfo<OrganizeLevelVO> getOrganizeLevelById(
            @Parameter(name = "ID") @PathVariable Long organizeLevelId) {
        return organizeLevelService.queryOrganizeLevelById(organizeLevelId);
    }

    /**
     * 分页查询组织级别
     * @param organizeLevelQueryDTO 组织级别参数
     * @return ResultInfo
     */
    @Operation(summary = "分页查询组织级别")
    @GetMapping("/getInfos")
    public ResultInfo<Page<OrganizeLevelVO>> getOrganizeLevelPage(
            @Validated OrganizeLevelDTO.QueryDTO organizeLevelQueryDTO) {
        return organizeLevelService.queryOrganizeLevelPage(organizeLevelQueryDTO);
    }

    /**
     * 根据条件查询组织级别
     * @param organizeLevelQueryDTO 组织级别参数
     * @return ResultInfo
     */
    @Operation(summary = "根据条件查询组织级别")
    @GetMapping("/getInfoList")
    public ResultInfo<List<OrganizeLevelVO>> getOrganizeLevelList(
            @Validated OrganizeLevelDTO.QueryDTO organizeLevelQueryDTO) {
        return organizeLevelService.queryOrganizeLevelList(organizeLevelQueryDTO);
    }

}
